#include <gtk/gtk.h>

cairo_surface_t *image = NULL; 

static gboolean on_window_expose_event(GtkWidget * widget,
	  GdkEventExpose * event, gpointer data)
{
	cairo_t *cr;

	cr = gdk_cairo_create(widget->window);
	cairo_set_source_surface(cr, image, 0, 0);
	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
	cairo_paint(cr);
	cairo_destroy(cr);
	return FALSE;
}

gint main(gint argc, gchar ** argv)
{
	GtkWidget *window;
	GdkScreen *screen;
	GdkColormap *colormap;

	gtk_init(&argc, &argv);

	image = cairo_image_surface_create_from_png("demo3.png");
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
	gtk_widget_set_app_paintable(window, TRUE);
	gtk_window_resize(GTK_WINDOW(window), 250, 250);
	g_signal_connect(G_OBJECT(window), "expose-event",
		  G_CALLBACK(on_window_expose_event), NULL);

	screen = gtk_widget_get_screen(window);
	colormap = gdk_screen_get_rgba_colormap(screen);
	gtk_widget_set_colormap(window, colormap);

	gtk_widget_show_all(window);
	gtk_main();
	return TRUE;
}

